<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator"></div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-form-item label="技师id" style="margin-right: 10px">
            <a-input placeholder="请输入技师id" v-model="queryParam.coachId" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="技师名称" style="margin-right: 10px">
            <a-input placeholder="请输入技师名称" v-model="queryParam.coachName" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="开始时间" style="margin-right: 10px">
            <a-date-picker v-model="queryParam.startTime" @change="startChange" :valueFormat="'YYYY-MM-DD'" />
          </a-form-item>
          <a-form-item label="结束时间" style="margin-right: 10px">
            <a-date-picker
              v-model="queryParam.endTime"
              @change="endChange"
              :valueFormat="'YYYY-MM-DD'"
              :disabled-date="disabledDate"
            />
          </a-form-item>
          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </span>
        </a-form>
      </div>
    </div>

    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
      <!-- 健康证 -->
      <template slot="workImg" slot-scope="text, record">
        <div class="anty-img-wrap">
          <a-avatar style="width: 80px; height: 80px" shape="square" :src="getAvatarView(record.workImg)" />
        </div>
      </template>

      <!-- 项目数据 -->
      <template slot="listServer" slot-scope="text, record">
        <div class="anty-img-wrap" v-for="item in record.listServer" style="display: flex; padding-left: 50px">
          <div style="width: 200px; display: flex">
            项目名：<span style="color: green">{{ item.title }}</span
            >;
          </div>

          <div style="width: 150px; display: flex">
            项目单价<span style="color: red">{{ item.price }}</span
            >;
          </div>

          <div style="width: 150px; display: flex">
            总共销售数量：<span style="color: red">{{ item.totalOrderNum }}</span
            >;
          </div>

          <div style="width: 150px; display: flex">
            升级数量：<span style="color: red">{{ item.upgradeOrderNum }}</span
            >;
          </div>

          <div style="width: 150px; display: flex">
            加钟数量<span style="color: red">{{ item.speedOrderNum }}</span
            >;
          </div>
        </div>
      </template>

      <span slot="action" slot-scope="text, record">
        <a @click="handleEdit(record)">编辑</a>

        <a-divider type="vertical" />
        <a-dropdown>
          <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </span>
    </a-table>

    <!-- table区域-end -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getFileAccessHttpUrl, getAction, httpAction } from '@/api/manage'
import serveSelect from '@/components/serveSelect.vue'

import moment from 'moment'
export default {
  name: 'xhdjFundLog',
  mixins: [JeecgListMixin],
  components: { serveSelect },
  data () {
    return {
      description: '技师分析',
      // 表头pickerOptions: {
      columns: [
        {
          title: '技师id',
          align: 'center',
          dataIndex: 'id'
        },
        {
          title: '技师昵称',
          align: 'center',
          dataIndex: 'coachName'
        },
        {
          title: '技师真实姓名',
          align: 'center',
          dataIndex: 'realName'
        },
        {
          title: '工作照',
          align: 'center',
          dataIndex: 'workImg',
          scopedSlots: { customRender: 'workImg' }
        },
        {
          title: '项目数据',
          align: 'center',
          dataIndex: 'listServer',
          scopedSlots: { customRender: 'listServer' }
        }
      ],
      url: {
        list: '/coach/xhdjCoachInfo/serveStatisticsList'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    disabledDate (time) {
      return new Date(time).getTime() < new Date(this.queryParam.startTime).getTime()
    },
    startChange (value) {
      if (value) {
        this.queryParam.startTime = value + ' 00:00:00'
      } else {
        this.queryParam.startTime = value
      }
    },
    endChange (value) {
      if (value) {
        this.queryParam.endTime = value + ' 23:59:59'
      } else {
        this.queryParam.endTime = value
      }
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
.ant-form {
  display: flex;
}
</style>
